<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Projeto!</title>
        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/reset.css"/>
        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/style.css"/>
        <script type="text/javascript" src="<?php echo base_url() ?>js/jquery-1.6.js"></script>
        <script type="text/javascript" src="<?php echo base_url() ?>js/jquery-ui-1.8.13.custom.min.js"></script>
        <script type="text/javascript" src="<?php echo base_url(); ?>js/core.js"></script>
        <style type="text/css">
        </style>
    </head>
    <body>
        <?php
        include ("includes/nav_bar.php");
        ?>
        <div id="main-content">
            <div id="conteudo">
                <h1>Ideias Ativas</h1>
                <?php if(isset($view_msg))
                    echo $view_msg; ?>
                <?php
                $i = 0;
                if(isset($view_ideias))
                    foreach($view_ideias as $ideia):
                        ?>
                        <a class="mostrar-ideia" href="<?php echo base_url()."ideias/verpostagem/id/{$ideia->Ideia_id}"; ?>">
                            <div class="post-esquerda">
                                <h2 style="display: inline-block; font-size: 18px;"><?php echo $ideia->Ideia_Titulo; ?></h2>
                                <p><br /><?php echo limitString($ideia->Ideia_Descricao, 244); ?><br /><br /></p>
                                <p style="font-size: 10px;">por <?php echo $ideia->Autor_Ideia; ?> em <?php echo $ideia->Categoria; ?></p>              
                                <div class="post-direita-top">
                                    <p><strong>Ultimo reply:</strong> <span><?php echo limitString($ideia->Reply, 144); ?></span></p>
                                </div>
                            </div>
                            <div class="clear"></div>
                        </a>
                        <?php
                        $i++;
                        if($i == 5)
                            break;
                        ?>
                    <?php endforeach; ?>
            </div>
        </div>
    </body>
</html>
<?php

function limitString($string, $limit) {
    if(strlen($string) > $limit) {
        $reply = substr($string, 0, $limit);
        if($reply[$limit - 1] == " ")
            $reply = substr($string, 0, $limit - 1);
        $reply .= "...";
    } else {
        $reply = $string;
    }
    return $reply;
}
?>